package baidu.hudson.plugin.result.collector.CCheckExtend;

import baidu.hudson.plugin.result.collector.utils.BuildAnalyzer;
import baidu.hudson.plugin.result.collector.utils.JsonUtils;
import hudson.model.AbstractBuild;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.EnumMap;
import java.util.Map;

/**
 * Created by IntelliJ IDEA.
 * User: Richard
 * Date: 4/24/11
 * Time: 2:49 PM
 * To change this template use File | Settings | File Templates.
 */
public class CCheckExtendedBuildAnalyzer extends BuildAnalyzer{
    private  AbstractBuild build;
    private String actionClassToken;
    public  CCheckExtendedBuildAnalyzer(AbstractBuild build, String actionClassToken){
        this.build = build;
        this.actionClassToken = actionClassToken;
    }

    @Override
    protected void addMoreValuePairsToContainer(Map<String, Object> valuePairsContainer) throws IOException, InvocationTargetException, NoSuchMethodException, IllegalAccessException, InstantiationException {
        super.addMoreValuePairsToContainer(valuePairsContainer);
         InformationAbstractor infoObject = new InformationAbstractor( build, actionClassToken);
         EnumMap<CCheckMethodEnum , String> map= infoObject.generateCCheckResultMap();
        valuePairsContainer.put(actionClassToken,map);
         String json = JsonUtils.getMapper().writeValueAsString(map);
    }

    public AbstractBuild getBuild() {
        return build;
    }

    public void setBuild(AbstractBuild build) {
        this.build = build;
    }

    public String getActionClassToken() {
        return actionClassToken;
    }

    public void setActionClassToken(String actionClassToken) {
        this.actionClassToken = actionClassToken;
    }
}
